package com.cyandpos.pad.attachselect.presenter;


import android.util.Log;

import com.cyandpos.pad.attachselect.model.IMemberModel;
import com.cyandpos.pad.attachselect.model.MemberModelImpl;
import com.cyandpos.pad.attachselect.view.IMemberView;
import com.cyandpos.pad.posdata.GetValueCardResponse;
import com.cyandpos.pad.posdata.GetVipCouponResponse;
import com.cyandpos.pad.posdata.QueryMemberInfoResponse;
import com.cyandpos.pad.posdata.QueryMemberRequest;

/**
 * Created by derek on 2017/5/9.
 */

public class MemberPresenterImpl implements IMemberPresenter {

    private IMemberView mIMemberView;
    private IMemberModel mIMemberModel;

    public MemberPresenterImpl(IMemberView iMemberView){
        this.mIMemberView = iMemberView;
        mIMemberModel = new MemberModelImpl();
    }

    /**
     * 查询会员信息
     * @param requestParam
     */
    @Override
    public void queryMemberDetail(QueryMemberRequest requestParam) {
        mIMemberView.showWaitDialog("信息查询中...");
        mIMemberModel.queryMemberDetail(requestParam, new IMemberModel.onQueryMemberDetailListener() {
            @Override
            public void onQueryMemberDetailSuccess(QueryMemberInfoResponse member) {
                mIMemberView.showMemberDetail(member);
                mIMemberView.dismissWaitDialog();
            }

            @Override
            public void onQueryMemberDetailFail(String errorMessage) {
                mIMemberView.dismissWaitDialog();
               // mIMemberView.onFail(errorMessage, MemberBaseFragment.QUERYMEMBERINFO);
            }
        });
    }



    /**
     * 查询卡券
     * @param requestParam
     */
    @Override
    public void queryMemberCoupon(QueryMemberRequest requestParam) {
        mIMemberView.showWaitDialog("券信息查询中...");
        mIMemberModel.queryMemberCoupon(requestParam, new IMemberModel.onQueryMemberCouponListener() {
            @Override
            public void onQueryMemberCouponSuccess(GetVipCouponResponse responseData) {
                Log.i("TAG----券信息查询中",responseData.toString());
                mIMemberView.dismissWaitDialog();
                mIMemberView.showCouponDetail(responseData);
            }

            @Override
            public void onQueryMemberCouponFail(String errorMessage) {
                mIMemberView.dismissWaitDialog();
               // mIMemberView.onFail(errorMessage, MemberBaseFragment.QUERYCOUPON);
                mIMemberView.onFail(errorMessage);
            }
        });
    }

    @Override
    public void queryMemberCent(QueryMemberRequest requestParam) {
        mIMemberView.showWaitDialog("积分查询中...");
        mIMemberModel.queryMemberDetail(requestParam, new IMemberModel.onQueryMemberDetailListener() {
            @Override
            public void onQueryMemberDetailSuccess(QueryMemberInfoResponse responseData) {
                Log.i("TAG----积分查询中",responseData.toString());
                mIMemberView.dismissWaitDialog();
                mIMemberView.showCentDetail(responseData);
            }

            @Override
            public void onQueryMemberDetailFail(String errorMessage) {
                mIMemberView.dismissWaitDialog();
                Log.i("TAG----积分查询中",errorMessage.toString());

                // mIMemberView.onFail(errorMessage, MemberBaseFragment.QUERYCOUPON);
                mIMemberView.onFail(errorMessage);
            }
        });
    }

    /**
     * 查询储值卡
     * @param requestParam
     */
    @Override
    public void queryValueCard(QueryMemberRequest requestParam) {
        mIMemberView.showWaitDialog("储值卡查询中...");
        mIMemberModel.queryValueCard(requestParam, new IMemberModel.onQueryValueCardListener() {
            @Override
            public void onQueryValueCardSuccess(GetValueCardResponse responseData) {
                Log.i("TAG----储值卡查询中", responseData.toString());

                mIMemberView.dismissWaitDialog();
                mIMemberView.showValueCard(responseData);
            }

            @Override
            public void onQueryValueCardFail(String errorMessage) {
                mIMemberView.dismissWaitDialog();
                Log.i("TAG----储值卡查询中", errorMessage.toString());
                mIMemberView.onFail(errorMessage);
            }
        });
    }

}
